<template>
  <div class="quitApproval">
    <div class="contLeft">
      <h2>{{ information.data.username }}申请调休</h2>
      <div class="topTit">
        <img src="@/assets/common/img.jpeg" alt>
        <div class="info">
          <p class="name">
            <strong>{{ information.username }}</strong>
          </p>
          <p>
            <span>部门：天津事业部</span>
          </p>
          <p>
            <span>申请时间： {{ information.data.approvalAdd }}</span>
          </p>
        </div>
      </div>
      <div class="content">
        <!-- <p v-for="(item, index) in information.body" :key="index"><span>{{item.key}} </span> {{item.val}}</p> -->
        <p>
          <span>补偿方式：</span>
          调休
        </p>
        <p>
          <span>调休开始时间：</span>
          {{ information.data.adaptationStart | formatDate }}
        </p>
        <p>
          <span>调休结束时间：</span>
          {{ information.data.adaptationStop | formatDate }}
        </p>
        <p>
          <span>申请原因：</span>
          {{ information.data.adaptationThing }}
        </p>
      </div>
    </div>
  </div>
</template>

<script>
import { getApprovalsDetail, getApprovalsTaskDetail, downImg } from '@/api/approval'
import {finApprovalById} from "@/api/approval"
export default {
  name: 'UsersTableIndex',
  data() {
    return {
      approvalId: this.$route.params.id,

      information: {
        data: {}
      },
      taskInstanceOutList: [],
      imgs: ''
    }
  },
  created() {
    this.finApprovalById()
    this.getApprovalsTaskDetail()
  },
  methods: {
    async finApprovalById() {
      this.information.data = await finApprovalById(this.approvalId)
      console.log(this.information)
      // this.information.data = JSON.parse(this.information.procData)
    },
    async getApprovalsDetail() {
      this.information = await getApprovalsDetail(this.approvalId)
      this.information.data = JSON.parse(this.information.procData)
    },
    async getApprovalsTaskDetail() {
      this.taskInstanceOutList = await getApprovalsTaskDetail(this.approvalId)
    },
    // 图片下载
    async getReviewHistory(id) {
      const response = await downImg(id)
      this.imgs = 'data:image/png;base64,' + btoa(
        new Uint8Array(response.request.response).reduce((data, byte) => data + String.fromCharCode(byte), '')
      )
    },
    imgHandle(obj) {
      return window.URL.createObjectURL(obj)
    }
  }
}
</script>
